<?php
/**
 * Truncate string.
 *
 * @author Anton Danilchenko <anton.danilchenko@gmail.com>
 */
class Templum_Helper_Crop implements Templum_Helper_Interface
{
	/**
	 * Return result of current helper.
	 *
	 * @param string $sData: processing string
	 * @param array $aParams: 0 - length, 1 - added suffix
	 */
	public function handle(&$sData, $aParams=array())
	{
		// check params
		$iLength = (isset($aParams[0])) ? $aParams[0] : 100;
		$sSuffix = (isset($aParams[1])) ? $aParams[1] : '...';
		// processing data
		$sData = substr($sData, 0, $iLength) . $sSuffix;
	}
}